package com.jielin.handling.web.schedulertask;

import com.jielin.handling.service.dzzj.VideoService;
import com.jielin.handling.service.policeplatform.PolicePlatformService;
import com.jielin.handling.service.record.RecordApplyService;
import com.jielin.handling.service.room.RoomInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class SchedulerTask {

    private int count = 0;

    @Autowired
    private VideoService videoService;

    @Autowired
    private PolicePlatformService policePlatformService;

    @Autowired
    private RoomInformationService roomInformationService;

    @Autowired
    private RecordApplyService recordApplyService;


//    @Scheduled(cron="*/6 * * * * ?")
//    private void process(){
//    	ApplicationContext applicationContext = SpringUtil.getApplicationContext();
//
//    	VideoService videoService = applicationContext.getBean(VideoService.class);
//
//    	videoService.makeInsertGrapherVideo();// 执行定时任务
//
//        System.out.println("this is scheduler task runing  "+(count++));
//    }


//    @Scheduled(cron="*/20 * * * * ?")
//    private void requestPolice(){
    //policePlatformService.requestPoliceData();// 执行定时任务获取案件信息

    // System.out.println("this is scheduler task runing  "+(count++));
//    }


//    @Scheduled(cron="*/20 * * * * ?")
//    private void  requestAwarn(){
    // policePlatformService.requestAwarning();// 执行定时任务获取告警提醒

    //System.out.println("this is scheduler task runing  "+(count++));
//    }


//    @Scheduled(cron="*/30 * * * * ?")
//    private void  requestResult(){
//        policePlatformService.grtResults();// 执行定时任务
//
//        System.out.println("this is scheduler task runing  "+(count++));
//    }


//    @Scheduled(cron="*/30 * * * * ?")
//    private void  requestOrg(){
    //videoService.updateRquestOrg();// 执行定时任务获取单位

    //System.out.println("this is scheduler task runing  "+(count++));
//    }


//    @Scheduled(cron="*/6 * * * * ?")
//    private void  requestExamination(){

    // policePlatformService.requestExamination();// 执行定时任务获取考核分数

    //System.out.println("this is scheduler task runing  "+(count++));
//    }


//    @Scheduled(cron="*/6 * * * * ?")
//    private void  requestSuperiorOrg(){

//        policePlatformService.requestSuperiorOrg();// 执行定时任务获取单位关系

    //  System.out.println("this is scheduler task runing  "+(count++));
//    }


//    @Scheduled(cron="0 0/5 * * * *")
//    private void  getRecordInfo(){
//
//        policePlatformService.getRecordInfo();// 执行定时任务获取三合一录音信息
//
//        System.out.println("this is scheduler task runing  "+(count++));
//    }

    /**
     * 30分钟执行一次，将房间预约超过30分钟没使用与使用超过4小时的房间重置为空闲状态
     */
    @Scheduled(cron = "*/30 * * * * ?")
    private void requestResult() {

        roomInformationService.resetRoomStatus();

//        System.out.println("this is scheduler task runing  " + (count++));
    }

    /**
     * 同步三台合一音频文件到电子卷宗
     */
//    @Scheduled(cron = "*/6 * * * * ?")
//    private void syncSTHYFileToDossierFile() {
//
//        videoService.syncSHYFilesToDossierFiles();
//
//        System.out.println("this is scheduler task runing  " + (count++));
//    }

    /**
     * 6秒执行一次，增量更新lucene索引
     */
//    @Scheduled(cron = "*/30 * * * * ?")
    @Scheduled(cron = "*/6 * * * * ?")
    private void updateRecordLuceneIndex() {

        recordApplyService.updateRecordLuceneIndex();

//        System.out.println("this is scheduler task runing  " + (count++));
    }
}